<?php include('connect.php');?>
<?php
	if(isset($_POST['hid'])){
		$email=base64_decode($_POST['hid']);
		$sql="select * from users_emails where email='".$email."' and status=0";
		$result=mysql_query($sql,$con);
		$row=mysql_num_rows($result);
		if($row==0){
		$sql1="update users_emails set status='0' where email='".$email."'";
		$res1=mysql_query($sql1,$con);
		if($res1==1){
		?>
			<script>alert("You are email is sucessfully unsubscribed.");</script>
		<?
		}
		}else{
		?>
		<script>alert("You are email is Allready unsubscribed.");</script>
		<?
		}
	}

?>
<html>
	<head>
		<title>
			UnSubScribe Aapthi News Letter
		</title>
	</head>
	<body>
		<center>
			<form id="unsubscribeForm" method="POST" action="">
				<h3>Unsubscribe from our newsletters</h3>
				<h3>Your email id is : <? if(isset($_GET['email'])){echo base64_decode($_GET['email']);}?></h3>
				<p>We are sorry to find you are not any longer interested in our newsletter.</p>
				<input type="hidden" id="hid" name="hid" value="<? if(isset($_GET['email'])){echo $_GET['email'];}?>">
				<input type="submit"  value="Unsubscribe">
			</form>
		</center>
	</body>
</html>